#!/bin/bash

if [ `ls /home/rover/USE_STARTUP` ]
then
RVR_ROOT=/home/rover/rover-2012/trunk/final/
export RVR_ROOT=$RVR_ROOT
make setup -C $RVR_ROOT
cp /var/log/connect.log.old /var/log/connect.log.old.old
cp /var/log/connect.log /var/log/connect.log.old
cp /var/log/run-rover.log.old /var/log/run-rover.log.old.old
cp /var/log/run-rover.log /var/log/run-rover.log.old
cp /var/log/camera1.log.old /var/log/camera1.log.old.old
cp /var/log/camera1.log /var/log/camera1.log.old
cp /var/log/camera2.log.old /var/log/camera2.log.old.old
cp /var/log/camera2.log /var/log/camera2.log.old
cp /var/log/high-quality.log.old /var/log/high-quality.log.old.old
cp /var/log/high-quality.log /var/log/high-quality.log.old
echo 'Done with setup. Sleeping 30 sec'
sleep 30
echo 'attempting to connect'
wvdial Verizon4GLTE &> /var/log/connect.log &
echo 'Sleeping for 15 sec'
sleep 15
echo 'starting run-rover'
make run-rover -C $RVR_ROOT &> /var/log/run-rover.log &
echo 'sleeping for 15 sec'
sleep 15
echo 'starting run-rover-camera1'
make run-rover-camera1 -C $RVR_ROOT &> /var/log/camera1.log &
echo 'starting run-rover-camera2'
make run-rover-camera2 -C $RVR_ROOT &> /var/log/camera2.log &
echo 'starting run-rover-high-quality'
make run-rover-high-quality -C $RVR_ROOT &> /var/log/high-quality &
fi
